<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace app\admin\controller;

/**
 * 前台首页控制器
 */
class Home extends AdminBase
{
   /**
    * 友情链接列表
    */ 
    public function friendshipList()
    {
        $where = $this->logicFriendship->getWhere($this->param);
        
        $d = $this->logicFriendship->getFriendshipList($where, 'a.*,p.path', 'a.updated_at desc');
        
        $this->assign('list', $this->logicFriendship->getFriendshipList($where, 'a.*,p.path', 'a.updated_at desc'));
        
        
        return $this->fetch('friendship_list');
    }
    
    /**
     * 编辑友情链接
     * @return type
     */
    
    public function friendshipEdit()
    {
        $this->friendshipCommon();
        
        $info = $this->logicFriendship->getFriendshipInfo(['a.id' => $this->param['id']]);
        
        !empty($info);
        
        $this->assign('info', $info);
        
        return $this->fetch('friendship_edit');
    }
    
    /**
     * 添加友情链接
     * @return type
     */
    public function friendshipAdd()
    {       
        $this->friendshipCommon();
        
        return $this->fetch('friendship_edit');
    }

    /**
     * 友情链接添加、编辑通用方法
     */
    public function friendshipCommon()
    {       
        IS_POST && $this->jump($this->logicFriendship->friendshipEdit($this->param));
    }
    
     /**
     * 更改友情链接状态  
     */
    public function setStatus()
    {
       $this->jump($this->logicAdminBase->setStatus('Friendship', $this->param));
    }
}